﻿Public Class PlugEinstieg

    Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugV1



    Private _createChildren As Boolean
    Private _transaktion As String
    Private _toolstripItem As System.Windows.Forms.ToolStrip


    Private _environment As LibMultiPlug.Core.Plugins.PluginEnvironment

    Public Sub New()
        _createChildren = True
        _transaktion = "pe00"
    End Sub

    Public Sub New(ByVal cc As Boolean, ByVal transaktion As String)
        _createChildren = cc
        _transaktion = transaktion
    End Sub

    Public Sub Action() Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugV1.Action

        'LibMultiPlug.Core.Statusmeldungen.Statusmeldungscontroller.SetLabelText(_transaktion, Drawing.Color.Red, 500)

        'Dim sb As New SpezialBenachrichtigung

        'sb.Benachrichtigungstext = "Benachrichtigung aus " & _transaktion

        'LibMultiPlug.Core.Benachrichtigungen.BenachrichtigungsManager.GetInstance().Benachrichtige(sb)

        Try
            Dim tf As New Testform
            tf.Text = _transaktion
            tf.Show(_environment.MainDockPanel)
        Catch ex As Exception
            System.Windows.Forms.MessageBox.Show(String.Format("Schöne Grüße aus dem Testplugin. Transaktion: {0}", _transaktion))
        End Try
    End Sub

    Public ReadOnly Property ActionText As String Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugV1.ActionText
        Get
            Return String.Format("Aktion {0}", _transaktion)
        End Get
    End Property

    Public ReadOnly Property Children As System.Collections.Generic.List(Of LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1) Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1.Children
        Get

            Dim lop As New List(Of LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1)

            If _createChildren Then
                lop.Add(New PlugEinstieg(False, "pe01"))
                lop.Add(New PlugEinstieg(False, "pe02"))
                lop.Add(New PlugEinstieg(False, "pe03"))
                lop.Add(New PlugEinstieg(False, "pe04"))
                For Each pe In lop
                    CType(pe, LibMultiPlug.Core.Plugins.Interfaces.IPlugV1).Initialize(_environment)
                Next
            End If

            Return lop
        End Get
    End Property

    Public ReadOnly Property Description As String Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugV1.Description
        Get

        End Get
    End Property

    Public ReadOnly Property Icon As System.Drawing.Bitmap Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugV1.Icon
        Get
            Return My.Resources.bell
        End Get
    End Property

    Public Event Initialized(ByVal sender As LibMultiPlug.Core.Plugins.Interfaces.IPlugV1) Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugV1.Initialized

    Public Event InitializeFailed(ByVal sender As LibMultiPlug.Core.Plugins.Interfaces.IPlugV1, ByVal message As String) Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugV1.InitializeFailed

    Public Sub Install() Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugV1.Install

    End Sub

    Public Property IsInitialized As Boolean Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugV1.IsInitialized
        Get

        End Get
        Set(ByVal value As Boolean)

        End Set
    End Property

    Public ReadOnly Property IsInstalled As Boolean Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugV1.IsInstalled
        Get

        End Get
    End Property

    Public ReadOnly Property Name As String Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugV1.Name
        Get
            Return "Testplugin"
        End Get
    End Property

    Public ReadOnly Property Transaktion As String Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugV1.Transaktion
        Get
            Return _transaktion
        End Get
    End Property

    Public ReadOnly Property Version As Short() Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugV1.Version
        Get

        End Get
    End Property

    Public ReadOnly Property ToolStrip As System.Windows.Forms.ToolStrip Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugV1.ToolStrip
        Get
            Return _toolstripItem
        End Get
    End Property

    Public Sub Initialize(ByVal environment As LibMultiPlug.Core.Plugins.PluginEnvironment) Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugV1.Initialize
        _environment = environment

        _toolstripItem = New System.Windows.Forms.ToolStrip
        _toolstripItem.Items.Add(_transaktion, My.Resources.bell)
        _toolstripItem.Text = _transaktion

        _toolstripItem.Visible = (_transaktion = "pe01") 'False
        AddHandler _toolstripItem.Items(0).Click, AddressOf Me.Action

    End Sub

    Public Sub StartTransaction(ByVal args() As String) Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1.StartTransaction

    End Sub

    Public ReadOnly Property Key As String Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1.Key
        Get
            Return "test_plugin_main"
        End Get
    End Property
End Class
